clear
cd "D:"
log using Replication.log, name(PSRM) replace
use ExperimentalResults.dta


*In the following, we follow the sequence of the presentation of experimental results in the manuscript
*We define a binary indicator to perform Fish-Pitman permutation tests
gen FPTestIndicator=0 if Treatment=="ControlGroup"
replace FPTestIndicator=1 if Treatment=="TreatmentGroup"




//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////    Main Data Analysis of Section "Expert Voters"    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
preserve
*First, we calculate the quality of democratic choice in each election period
gen RightChoice=0 if Expertise==1&Vote!=State&Willingness2Vote>=RandVotingCost
replace RightChoice=1 if Vote==State&Expertise==1&Willingness2Vote>=RandVotingCost
gen WrongChoice=0 if Expertise==1&Vote==State&Willingness2Vote>=RandVotingCost
replace WrongChoice=1 if Vote!=State&Vote<3&Expertise==1&Willingness2Vote>=RandVotingCost

by ElectionID, sort: egen NRightChoice=total(RightChoice)
by ElectionID, sort: egen NWrongChoice=total(WrongChoice)

gen SumRightVotes=NRightChoice+2 if Supportive==1
replace SumRightVotes=NRightChoice+1 if Neutral==1
replace SumRightVotes=NRightChoice if Against==1
gen SumWrongVotes=NWrongChoice+2 if Against==1
replace SumWrongVotes=NWrongChoice+1 if Neutral==1
replace SumWrongVotes=NWrongChoice if Supportive==1

gen ProbRight=1 if SumRightVotes>SumWrongVotes
replace ProbRight=0 if SumRightVotes<SumWrongVotes
replace ProbRight=0.5 if SumRightVotes==SumWrongVotes

sort ElectionID
by ElectionID: gen Quality=ProbRight if _n==1

*Then, we use electorate verages as the unit of observation, 
*leaving us with 12 independent electorates for each treatment group 
sort ElectorateID
by ElectorateID: egen AverageQuality=mean(Quality)
by ElectorateID: gen AQuality=AverageQuality if _n==1

*Check the electorate averages of the quality of democratic choice by treatment
mean AQuality if Treatment=="ControlGroup"
mean AQuality if Treatment=="TreatmentGroup"

*Perform t-test, Mann-Whitney ranksum tests, and Fisher-Pitman permutation tests
ttest AQuality,by(Treatment)
ranksum AQuality,by(Treatment)
permtest2 AQuality,by(FPTestIndicator)
restore



//////////////////////////////////////////////////////////////////////////
//////    Examine the average Willingness to vote by treatment     ///////
//////////////////////////////////////////////////////////////////////////

preserve
*In this section, we focus on the analysis of expert voters' willingness to vote
*As reported later, non-expert voters' in most cases do not vote. 
*Non-expert voters' willingness to vote is close to zero.
drop if Expertise==0 
*We use the subject level averages of willingness to vote
sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

mean AVotingCutOff if Treatment=="ControlGroup"
mean AVotingCutOff if Treatment=="TreatmentGroup"

ttest AVotingCutOff,by(Treatment)
ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore


//////////////////////////////////////////////////////////////////////////
////////////////                Figure 2                 /////////////////
//////////////////////////////////////////////////////////////////////////
//Based on the information elicted from above, we know expert voters' WTV in the Control is 40.3, in the Treatment is 24.9//
//Based on the information elicted from Stata do code Line193 (below), we know non-expert voters' WTV in the Control is 2.0, in the Treatment is 1.3//  
//Thenn, we report both expert and non-expert voters' WTV together and make Figure 2 using the following codes//
preserve
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure2Expert") firstrow
twoway (bar Mean Position if Treatment=="ControlGroup",  name(ExpertWTV,replace) fcolor(gs6) bcolor(gs4) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="TreatmentGroup",  fcolor(gs14) bcolor(gs4) lwidth(0.4)  )||(rcap CI95L CI95H Position,lcolor(gs4)  yaxis(1) lwidth(0.4)),  ylabel(0 (10) 60,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Willingness to vote",size(large)) ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(1 "Control") label(2 "Treatment") label(3 "95% CI")) title("Expert Voters",color(black))  graphregion(color(white)) plotregion(color(white))  text(5.5 1 "40.3",place(c) size(huge) color(black)) text(5.5 2 "24.9",place(c) size(huge) color(black))  
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure2NonExpert") firstrow
twoway (bar Mean Position if Treatment=="ControlGroup",  name(NonExpertWTV,replace) fcolor(gs6) bcolor(gs4) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="TreatmentGroup",  fcolor(gs14) bcolor(gs4) lwidth(0.4)  )||(rcap CI95L CI95H Position,lcolor(gs4)  yaxis(1) lwidth(0.4)),  ylabel(0 (10) 60,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Willingness to vote",size(large)) ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(1 "Control") label(2 "Treatment") label(3 "95% CI")) title("Non-Expert Voters",color(black))  graphregion(color(white)) plotregion(color(white))  text(5.5 1 "2.0",place(c) size(huge) color(black)) text(5.5 2 "1.3",place(c) size(huge) color(black))  
graph combine ExpertWTV NonExpertWTV, name(Figure2,replace) col(2) graphregion(color(white)) plotregion(color(white)) note("Note: We average (non)expert voters' willingness to vote and use electorate level averages as the unit of" "independent observation in the statistical analysis.",span)
graph export "D:\Figure2.pdf", as(pdf) replace
restore



//////////////////////////////////////////////////////////////////////////
//Examine the average Willingness to vote by treatment and partisan bias//
//////////////////////////////////////////////////////////////////////////

*When partisan bias is against
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Against==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Against==1
preserve
drop if Expertise==0
drop if Against!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore



*When partisan bias is neutral
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Neutral==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Neutral==1
preserve
drop if Expertise==0
drop if Neutral!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore



*When partisan bias is supportive
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Supportive==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Supportive==1
preserve
drop if Expertise==0
drop if Supportive!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore



//////////////////////////////////////////////////////////////////////////
////////////////                Figure 3                 /////////////////
//////////////////////////////////////////////////////////////////////////
//Start from Line 168, end at Line 378//
preserve
//We elicit expert voters' WTV of the Treatment Group by the number of realized expert voters and partisan bias using the following codes//
//The mean and corresponding confidence intervals are manually clustered at the subject level//
drop if Expertise==0
drop if Treatment=="ControlGroup"
sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive1=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesSupportive1=mean(MeanWTVSupportive1)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive1=AvergesSupportive1 if _n==1
mean AVotingCutOffSupportive1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive2=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesSupportive2=mean(MeanWTVSupportive2)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive2=AvergesSupportive2 if _n==1
mean AVotingCutOffSupportive2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive3=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesSupportive3=mean(MeanWTVSupportive3)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive3=AvergesSupportive3 if _n==1
mean AVotingCutOffSupportive3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive4=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesSupportive4=mean(MeanWTVSupportive4)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive4=AvergesSupportive4 if _n==1
mean AVotingCutOffSupportive4

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive5=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesSupportive5=mean(MeanWTVSupportive5)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive5=AvergesSupportive5 if _n==1
mean AVotingCutOffSupportive5

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral1=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesNeutral1=mean(MeanWTVNeutral1)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral1=AvergesNeutral1 if _n==1
mean AVotingCutOffNeutral1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral2=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesNeutral2=mean(MeanWTVNeutral2)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral2=AvergesNeutral2 if _n==1
mean AVotingCutOffNeutral2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral3=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesNeutral3=mean(MeanWTVNeutral3)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral3=AvergesNeutral3 if _n==1
mean AVotingCutOffNeutral3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral4=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesNeutral4=mean(MeanWTVNeutral4)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral4=AvergesNeutral4 if _n==1
mean AVotingCutOffNeutral4


sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral5=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesNeutral5=mean(MeanWTVNeutral5)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral5=AvergesNeutral5 if _n==1
mean AVotingCutOffNeutral5


sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst1=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesAgainst1=mean(MeanWTVAgainst1)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst1=AvergesAgainst1 if _n==1
mean AVotingCutOffAgainst1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst2=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesAgainst2=mean(MeanWTVAgainst2)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst2=AvergesAgainst2 if _n==1
mean AVotingCutOffAgainst2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst3=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesAgainst3=mean(MeanWTVAgainst3)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst3=AvergesAgainst3 if _n==1
mean AVotingCutOffAgainst3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst4=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesAgainst4=mean(MeanWTVAgainst4)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst4=AvergesAgainst4 if _n==1
mean AVotingCutOffAgainst4

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst5=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesAgainst5=mean(MeanWTVAgainst5)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst5=AvergesAgainst5 if _n==1
mean AVotingCutOffAgainst5
restore


preserve
//We elicit expert voters' WTV of the Control Group by the number of realized expert voters and partisan bias using the following codes//
//The mean and corresponding confidence intervals are manually clustered at the subject level//

drop if Expertise==0
drop if Treatment=="TreatmentGroup"
sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive1=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesSupportive1=mean(MeanWTVSupportive1)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive1=AvergesSupportive1 if _n==1
mean AVotingCutOffSupportive1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive2=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesSupportive2=mean(MeanWTVSupportive2)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive2=AvergesSupportive2 if _n==1
mean AVotingCutOffSupportive2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive3=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesSupportive3=mean(MeanWTVSupportive3)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive3=AvergesSupportive3 if _n==1
mean AVotingCutOffSupportive3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive4=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesSupportive4=mean(MeanWTVSupportive4)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive4=AvergesSupportive4 if _n==1
mean AVotingCutOffSupportive4

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVSupportive5=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesSupportive5=mean(MeanWTVSupportive5)
by GlobalSubjectID, sort: gen AVotingCutOffSupportive5=AvergesSupportive5 if _n==1
mean AVotingCutOffSupportive5

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral1=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesNeutral1=mean(MeanWTVNeutral1)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral1=AvergesNeutral1 if _n==1
mean AVotingCutOffNeutral1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral2=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesNeutral2=mean(MeanWTVNeutral2)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral2=AvergesNeutral2 if _n==1
mean AVotingCutOffNeutral2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral3=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesNeutral3=mean(MeanWTVNeutral3)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral3=AvergesNeutral3 if _n==1
mean AVotingCutOffNeutral3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral4=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesNeutral4=mean(MeanWTVNeutral4)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral4=AvergesNeutral4 if _n==1
mean AVotingCutOffNeutral4


sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVNeutral5=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesNeutral5=mean(MeanWTVNeutral5)
by GlobalSubjectID, sort: gen AVotingCutOffNeutral5=AvergesNeutral5 if _n==1
mean AVotingCutOffNeutral5


sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst1=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==1
by GlobalSubjectID, sort: egen AvergesAgainst1=mean(MeanWTVAgainst1)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst1=AvergesAgainst1 if _n==1
mean AVotingCutOffAgainst1

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst2=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==2
by GlobalSubjectID, sort: egen AvergesAgainst2=mean(MeanWTVAgainst2)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst2=AvergesAgainst2 if _n==1
mean AVotingCutOffAgainst2

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst3=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==3
by GlobalSubjectID, sort: egen AvergesAgainst3=mean(MeanWTVAgainst3)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst3=AvergesAgainst3 if _n==1
mean AVotingCutOffAgainst3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst4=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==4
by GlobalSubjectID, sort: egen AvergesAgainst4=mean(MeanWTVAgainst4)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst4=AvergesAgainst4 if _n==1
mean AVotingCutOffAgainst4

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVAgainst5=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==5
by GlobalSubjectID, sort: egen AvergesAgainst5=mean(MeanWTVAgainst5)
by GlobalSubjectID, sort: gen AVotingCutOffAgainst5=AvergesAgainst5 if _n==1
mean AVotingCutOffAgainst5
restore

preserve
//Then, based on the information elicted above, we make Figure 3 using the following codes//
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure3") firstrow
replace Nexpertise=Nexpertise+0.2 if Group=="Treatment"
twoway (rspike High95CI Low95CI Nexpertise if Group=="Control"&Partisan=="Supportive",  name(Figure3Supportive,replace) fcolor(gs10) bcolor(gs10) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(line Mean Nexpertise if Group=="Control"&Partisan=="Supportive",lcolor(gs14) lpattern(solid))||(scatter Mean Nexpertise if Group=="Control"&Partisan=="Supportive",  mcolor(gs6) msize(vlarge) msymbol(S)  )||(rspike High95CI Low95CI Nexpertise if Group=="Treatment"&Partisan=="Supportive",lcolor(gs10)  yaxis(1) lwidth(0.4))||(line Mean Nexpertise if Group=="Treatment"&Partisan=="Supportive",lcolor(gs14) lpattern(dash))||(scatter Mean Nexpertise if Group=="Treatment"&Partisan=="Supportive",  mcolor(gs6) msize(vlarge) msymbol(C)  ),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel(1.05 "1" 2.05 "2" 3.05 "3" 4.05 "4" 5.05 "5") xlabel("",axis(2)) ytitle("") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))  title("Supportive",color(black))   legend(region(lcolor(white))  order(3 6 1) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(3 "Control") label(6 "Treatment") label(1 "95% CI")) graphregion(color(white)) plotregion(color(white))  
twoway (rspike High95CI Low95CI Nexpertise if Group=="Control"&Partisan=="Neutral",  name(Figure3Neutral,replace) fcolor(gs10) bcolor(gs10) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(line Mean Nexpertise if Group=="Control"&Partisan=="Neutral",lcolor(gs14) lpattern(solid))||(scatter Mean Nexpertise if Group=="Control"&Partisan=="Neutral",  mcolor(gs6) msize(vlarge) msymbol(S)  )||(rspike High95CI Low95CI Nexpertise if Group=="Treatment"&Partisan=="Neutral",lcolor(gs10)  yaxis(1) lwidth(0.4))||(line Mean Nexpertise if Group=="Treatment"&Partisan=="Neutral",lcolor(gs14) lpattern(dash))||(scatter Mean Nexpertise if Group=="Treatment"&Partisan=="Neutral",  mcolor(gs6) msize(vlarge) msymbol(C)  ),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel(1.05 "1" 2.05 "2" 3.05 "3" 4.05 "4" 5.05 "5") xlabel("",axis(2)) ytitle("") ytitle("",axis(2)) xtitle("") xtitle("",axis(2)) title("Neutral",color(black))    legend(region(lcolor(white))  order(3 6 1) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(3 "Control") label(6 "Treatment") label(1 "95% CI")) graphregion(color(white)) plotregion(color(white))  
twoway (rspike High95CI Low95CI Nexpertise if Group=="Control"&Partisan=="Against",  name(Figure3Against,replace) fcolor(gs10) bcolor(gs10) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(line Mean Nexpertise if Group=="Control"&Partisan=="Against",lcolor(gs14) lpattern(solid))||(scatter Mean Nexpertise if Group=="Control"&Partisan=="Against",  mcolor(gs6) msize(vlarge) msymbol(S)  )||(rspike High95CI Low95CI Nexpertise if Group=="Treatment"&Partisan=="Against",lcolor(gs10)  yaxis(1) lwidth(0.4))||(line Mean Nexpertise if Group=="Treatment"&Partisan=="Against",lcolor(gs14) lpattern(dash))||(scatter Mean Nexpertise if Group=="Treatment"&Partisan=="Against",  mcolor(gs6) msize(vlarge) msymbol(C)  ),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel(1.05 "1" 2.05 "2" 3.05 "3" 4.05 "4" 5.05 "5") xlabel("",axis(2)) ytitle("") ytitle("",axis(2)) xtitle("") xtitle("",axis(2)) title("Against",color(black))    legend(region(lcolor(white))  order(3 6 1) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(3 "Control") label(6 "Treatment") label(1 "95% CI")) graphregion(color(white)) plotregion(color(white))  
graph combine Figure3Against Figure3Neutral Figure3Supportive, name(Figure3,replace) graphregion(color(white)) plotregion(color(white)) row(1) l1("Willingness to Vote") b1("Number of Realized Expert Voters") note("Note: In both the Control Group and the Treatment Group, on average about 70% of subjects have expertise in each election. There are few observations in" "which there are only one expert voter. For the cases in which there are only one expert voter, the lower bound of 95% CI is restrict at 0 and the upper bound" "of 95% CI is restrict at 100.")
graph display Figure3, xsize(12) ysize(6)
graph export "D:\Figure3.pdf", as(pdf) replace
restore

//////////////////////////////////////////////////////////////////////////
////////////////                Figure 4                 /////////////////
//////////////////////////////////////////////////////////////////////////
preserve
//We identify the distribution of expert voters' willingness to vote by treatment and partisan bias using the following codes//
tab Willingness2Vote if Expertise==1&Treatment=="ControlGroup"
tab Willingness2Vote if Expertise==1&Treatment=="TreatmentGroup"
tab Willingness2Vote if Expertise==1&Treatment=="ControlGroup"&Supportive==1
tab Willingness2Vote if Expertise==1&Treatment=="TreatmentGroup"&Supportive==1
tab Willingness2Vote if Expertise==1&Treatment=="ControlGroup"&Neutral==1
tab Willingness2Vote if Expertise==1&Treatment=="TreatmentGroup"&Neutral==1
tab Willingness2Vote if Expertise==1&Treatment=="ControlGroup"&Against==1
tab Willingness2Vote if Expertise==1&Treatment=="TreatmentGroup"&Against==1

//Then, based on the information elicted above, we make Figure 4 using the following codes//
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure4") firstrow
twoway (line CDF WTV if Category=="Control"&Selection=="Pool", name(pooledCDF,replace) lcolor(gs6) lpattern(solid) lwidth(thick))||(line CDF WTV if Category=="Treatment"&Selection=="Pool", lcolor(gs10) lpattern(dash) lwidth(thick)),ylabel(0 (25) 100,axis(1) nogrid)  xlabel(0 (25) 100,axis(1) nogrid) ytitle("",axis(1))   xtitle("",axis(1)) title("Pooled",color(black))   graphregion(color(white)) plotregion(color(white)) legend(region(lcolor(white))  order(1 2) ring(0) position(5) symxsize(5) keygap(Medium)  row(1) label(1 "Control Group") label(2 "Treatment Group")) 
twoway (line CDF WTV if Category=="Control"&Selection=="Against", name(againstCDF,replace) lcolor(gs6) lpattern(solid) lwidth(thick))||(line CDF WTV if Category=="Treatment"&Selection=="Against", lcolor(gs10) lpattern(dash) lwidth(thick)),ylabel(0 (25) 100,axis(1) nogrid)  xlabel(0 (25) 100,axis(1) nogrid) ytitle("",axis(1))   xtitle("",axis(1))  title("Against",color(black))   graphregion(color(white)) plotregion(color(white)) legend(region(lcolor(white))  order(1 2) ring(0) position(5) symxsize(Medium) keygap(Medium)  row(1) label(1 "Control Group") label(2 "Treatment Group")) 
twoway (line CDF WTV if Category=="Control"&Selection=="Neutral", name(neutralCDF,replace) lcolor(gs6) lpattern(solid) lwidth(thick))||(line CDF WTV if Category=="Treatment"&Selection=="Neutral", lcolor(gs10) lpattern(dash) lwidth(thick)),ylabel(0 (25) 100,axis(1) nogrid)  xlabel(0 (25) 100,axis(1) nogrid) ytitle("",axis(1))   xtitle("",axis(1))  title("Neutral",color(black))   graphregion(color(white)) plotregion(color(white)) legend(region(lcolor(white))  order(1 2) ring(0) position(5) symxsize(Medium) keygap(Medium)  row(1) label(1 "Control Group") label(2 "Treatment Group")) 
twoway (line CDF WTV if Category=="Control"&Selection=="Supportive", name(supportiveCDF,replace) lcolor(gs6) lpattern(solid) lwidth(thick))||(line CDF WTV if Category=="Treatment"&Selection=="Supportive", lcolor(gs10) lpattern(dash) lwidth(thick)),ylabel(0 (25) 100,axis(1) nogrid)  xlabel(0 (25) 100,axis(1) nogrid) ytitle("",axis(1))   xtitle("",axis(1))  title("Supportive",color(black))   graphregion(color(white)) plotregion(color(white)) legend(region(lcolor(white))  order(1 2) ring(0) position(5) symxsize(Medium) keygap(Medium)  row(1) label(1 "Control Group") label(2 "Treatment Group")) 
grc1leg pooledCDF againstCDF neutralCDF supportiveCDF, name(Figure4,replace) col(2) l1("CDF of Observed Willingness to Vote (%)") b1("Willingness to Vote") graphregion(color(white)) plotregion(color(white))
graph display Figure4,xsize(12) ysize(12)
graph export "D:\Figure4.pdf", as(pdf) replace
restore








//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////   Main Data Analysis of Section "Non-Expert Voters" ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
preserve
*In this section, we focus on the analysis of non-expert voters' behavior
drop if Expertise==1
gen Abstain=0
replace Abstain=1 if Vote==3

sort GlobalSubjectID
by GlobalSubjectID, sort: egen AbstainX=mean(Abstain)
by GlobalSubjectID, sort: gen NonExpertAbstain=AbstainX if _n==1
*The average frequency that non-expert voters abstain
mean NonExpertAbstain

*The average willingness to vote of non-expert voters by treatment
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

*Perform t-test, Mann-Whitney ranksum tests, and Fisher-Pitman permutation tests
ttest AVotingCutOff,by(Treatment)
ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)

gen NonExpertVotingNotCounted=1
replace NonExpertVotingNotCounted=0 if Willingness2Vote>=RandVotingCost
sort GlobalSubjectID
by GlobalSubjectID, sort: egen NotCounted=mean(NonExpertVotingNotCounted)
by GlobalSubjectID, sort: gen NonExpertVotesNotCounted=NotCounted if _n==1
*The average frequency that non-expert voters' ballots were not counted in experiments
mean NonExpertVotesNotCounted
restore

////////////////////////////////////////////////////////////////////////////////////
//A kind of difference-in-differences analysis of willingness to vote by treatment//
////////////////////////////////////////////////////////////////////////////////////

preserve
*First, generate average willingness to vote of expert voters
sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVI=mean(Willingness2Vote) if Expertise==1
by GlobalSubjectID, sort: egen MeanWTVIX=mean(MeanWTVI)
by GlobalSubjectID, sort: gen AVotingCutOffI=MeanWTVIX if _n==1
mean AVotingCutOffI if Treatment=="ControlGroup"
mean AVotingCutOffI if Treatment=="TreatmentGroup"
*Then, generate average willingness to vote of non-expert voters
sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTVUI=mean(Willingness2Vote) if Expertise==0
by GlobalSubjectID, sort: egen MeanWTVUIX=mean(MeanWTVUI)
by GlobalSubjectID, sort: gen AVotingCutOffUI=MeanWTVUIX if _n==1
mean AVotingCutOffUI if Treatment=="ControlGroup"
mean AVotingCutOffUI if Treatment=="TreatmentGroup"
*Perform Mann-Whitney signrank tests, and Fisher-Pitman permutation tests
*to examine whether expert-voters' willingness to vote are different from non-expert voters
signrank AVotingCutOffI=AVotingCutOffUI if Treatment=="ControlGroup"
permtest1 AVotingCutOffI=AVotingCutOffUI if Treatment=="ControlGroup"

signrank AVotingCutOffI=AVotingCutOffUI if Treatment=="TreatmentGroup"
permtest1 AVotingCutOffI=AVotingCutOffUI if Treatment=="TreatmentGroup"

*Generate subject-level average differences of willingness to vote between being experts and being non-experts
gen DiffCutoffVoting=AVotingCutOffI-AVotingCutOffUI
*Perform t-test, Mann-Whitney ranksum tests, and Fisher-Pitman permutation tests
*to examine whether the differences are different between treatments
ttest DiffCutoffVoting,by(Treatment)
ranksum DiffCutoffVoting,by(Treatment)
permtest2 DiffCutoffVoting,by(FPTestIndicator)
restore



//////////////////////////////////////////////////////////////////////////
////////////////                Figure 5                 /////////////////
//////////////////////////////////////////////////////////////////////////
preserve
//Based on the information elicted above, we make Figure 5 using the following codes//
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure5") firstrow
twoway (bar Mean Position if Treatment=="ControlGroup",  name(Figure5,replace) fcolor(gs6) bcolor(gs4) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="TreatmentGroup",  fcolor(gs14) bcolor(gs4) lwidth(0.4)  )||(rcap CI95L CI95H Position,lcolor(gs4)  yaxis(1) lwidth(0.4)),  ylabel(0 (10) 60,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("{&Delta} Willingness to vote between Expert and Non-Expert",size(3)) ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3) ring(0) position(1) symxsize(Medium) keygap(tiny)  row(3) label(1 "Control") label(2 "Treatment") label(3 "95% CI")) graphregion(color(white)) plotregion(color(white))  text(8 1 "38.3",place(c) size(huge) color(black)) text(8 2 "23.7",place(c) size(huge) color(black))  note("Note: We average (non)expert voters' willingness to vote and use electorate" "averages as the unit of independent observation in the statistical analysis.",span)
graph display Figure5, xsize(6) ysize(6)
graph export "D:\Figure5.pdf", as(pdf) replace
restore













//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
///////// Main Data Analysis of Section "Maximum Engagement" ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////


/////////  Calculations of Maximum Engagement in Section 4.1  ////////

preserve
clear
set obs 1000
gen rho=_n
replace rho=rho*0.001
gen Quality=(1/3)*(2-(3/2)*(1-rho)^5-5*rho*(1-rho)^4-(1/2)*10*rho^2*(1-rho)^3)+1/3
tab Quality if _n==700
restore

//Compare Experimental Quality of Democratic Choice to Max. Enagement Benchmark//

preserve
gen RightChoice=0 if Expertise==1&Vote!=State&Willingness2Vote>=RandVotingCost
replace RightChoice=1 if Vote==State&Expertise==1&Willingness2Vote>=RandVotingCost
gen WrongChoice=0 if Expertise==1&Vote==State&Willingness2Vote>=RandVotingCost
replace WrongChoice=1 if Vote!=State&Vote<3&Expertise==1&Willingness2Vote>=RandVotingCost

by ElectionID, sort: egen NRightChoice=total(RightChoice)
by ElectionID, sort: egen NWrongChoice=total(WrongChoice)

gen SumRightVotes=NRightChoice+2 if Supportive==1
replace SumRightVotes=NRightChoice+1 if Neutral==1
replace SumRightVotes=NRightChoice if Against==1
gen SumWrongVotes=NWrongChoice+2 if Against==1
replace SumWrongVotes=NWrongChoice+1 if Neutral==1
replace SumWrongVotes=NWrongChoice if Supportive==1

gen ProbRight=1 if SumRightVotes>SumWrongVotes
replace ProbRight=0 if SumRightVotes<SumWrongVotes
replace ProbRight=0.5 if SumRightVotes==SumWrongVotes

sort ElectionID
by ElectionID: gen Quality=ProbRight if _n==1


sort ElectorateID
by ElectorateID: egen AverageQuality=mean(Quality)
by ElectorateID: gen AQuality=AverageQuality if _n==1


mean AQuality if Treatment=="ControlGroup"
mean AQuality if Treatment=="TreatmentGroup"

*Perform Mann-Whitney signrank tests, and Fisher-Pitman permutation tests
*to examine whether the experimental results of quality of democratic choice 
*are different from the Max. Engagement Benchmark
signrank AQuality=0.97 if Treatment=="ControlGroup"
permtest1 AQuality=0.97 if Treatment=="ControlGroup"

signrank AQuality=0.97 if Treatment=="TreatmentGroup"
permtest1 AQuality=0.97 if Treatment=="TreatmentGroup"
restore

//////////////////////////////////////////////////////////////////////////
////////////////                Figure 6                 /////////////////
//////////////////////////////////////////////////////////////////////////
preserve
//Based on the information elicted above, we make Figure 6 using the following codes//
clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure6") firstrow
twoway (bar Mean Position if Treatment=="ControlGroup",  name(Figure6,replace) fcolor(gs14) bcolor(gs4) lwidth(0.4) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="TreatmentGroup",  fcolor(gs6) bcolor(gs4) lwidth(0.4)  )||(bar Mean Position if Treatment=="Ideal",  fcolor(white) bcolor(gs4) lwidth(0.4)  ),  ylabel(0.5 (0.1) 1,nogrid) ylabel("",axis(2)) xlabel("",axis(1)) xlabel("",axis(2)) ytitle("Quality of Democratic Choice",size(large) height(5)) ytitle("",axis(2)) xtitle("") xtitle("",axis(2))       graphregion(color(white)) plotregion(color(white)) legend(off) text(0.84 0.5 "Max",place(c) size(3) color(black)) text(0.82 0.5 "Engagement",place(c) size(3) color(black)) text(0.8 0.5 "Benchmark",place(c) size(3) color(black)) text(0.70 1.5 "Control",place(c) size(3) color(black)) text(0.68 1.5 "Group",place(c) size(3) color(black)) text(0.62 2.5 "Treatment",place(c) size(3) color(black)) text(0.60 2.5 "Group",place(c) size(3) color(black)) text(0.54 0.5 "0.97",place(c) size(huge) color(black)) text(0.54 1.5 "0.76",place(c) size(huge) color(black)) text(0.54 2.5 "0.64",place(c) size(huge) color(black)) note("Note: In both the control and treatment groups, the estimates are based on" "actual votes of expert voters whose willingness to vote {&ge} voting cost. We" "use electorate as the unit of independent observation. We use electorate" "level averages in the analysis and perform Mann-Whitney and exact" "Fisher-Pitman permutation tests. The achieved quality of democratic" "choice in each group is smaller than the max. eng. benchmark (p<0.003)." ,span)
graph display Figure6, xsize(6) ysize(6)
graph export "D:\Figure6.pdf", as(pdf) replace
restore


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
///////// Main Data Analysis of Section "Utilitarian Planner" ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

*We compare experimental data of willingness to vote and the quality of democratic choice
*to the Utilitarian Planner's prescriptions illustrated in Figure 7
*In this Empirical Replication file, we focus on the statistical analysis
*The calculations of the utilitarian planner's prescriptions are detailed in Online Appendix I 

preserve
*We first focus on the behavior of expert voters in the Treatment Group
drop if Expertise==0
drop if Treatment=="ControlGroup"


/////////When Partisan Bias was Against and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst1=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesAgainst1=mean(MeanWTVAgainst1)
by ElectorateID, sort: gen AVotingCutOffAgainst1=AvergesAgainst1 if _n==1
gen QualityTreatmentAgaN1=0
mean AVotingCutOffAgainst1
mean QualityTreatmentAgaN1
signrank  AVotingCutOffAgainst1=0
permtest1  AVotingCutOffAgainst1=0

/////////When Partisan Bias was Against and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst2=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesAgainst2=mean(MeanWTVAgainst2)
by ElectorateID, sort: gen AVotingCutOffAgainst2=AvergesAgainst2 if _n==1
gen QualityTreatmentAgaN2=(AVotingCutOffAgainst2/100)^2
mean AVotingCutOffAgainst2
mean QualityTreatmentAgaN2
signrank QualityTreatmentAgaN2=1
permtest1 QualityTreatmentAgaN2=1
signrank  AVotingCutOffAgainst2=100
permtest1  AVotingCutOffAgainst2=100

/////////When Partisan Bias was Against and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst3=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesAgainst3=mean(MeanWTVAgainst3)
by ElectorateID, sort: gen AVotingCutOffAgainst3=AvergesAgainst3 if _n==1
gen QualityTreatmentAgaN3=comb(3,3)*(AVotingCutOffAgainst3/100)^3+0.5*comb(3,2)*((AVotingCutOffAgainst3/100)^2)*(1-(AVotingCutOffAgainst3/100))
mean AVotingCutOffAgainst3
mean QualityTreatmentAgaN3
signrank QualityTreatmentAgaN3=1
permtest1 QualityTreatmentAgaN3=1
signrank  AVotingCutOffAgainst3=100
permtest1  AVotingCutOffAgainst3=100

/////////When Partisan Bias was Against and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst4=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesAgainst4=mean(MeanWTVAgainst4)
by ElectorateID, sort: gen AVotingCutOffAgainst4=AvergesAgainst4 if _n==1
gen QualityTreatmentAgaN4=comb(4,3)*((AVotingCutOffAgainst4/100)^3)*(1-(AVotingCutOffAgainst4/100))+0.5*comb(4,2)*((AVotingCutOffAgainst4/100)^2)*(1-(AVotingCutOffAgainst3/100)^2)
mean AVotingCutOffAgainst4
mean QualityTreatmentAgaN4
signrank QualityTreatmentAgaN4=0.951638
permtest1 QualityTreatmentAgaN4=0.951638
signrank  AVotingCutOffAgainst4=86.7
permtest1  AVotingCutOffAgainst4=86.7

/////////When Partisan Bias was Against and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst5=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesAgainst5=mean(MeanWTVAgainst5)
by ElectorateID, sort: gen AVotingCutOffAgainst5=AvergesAgainst5 if _n==1
gen QualityTreatmentAgaN5=comb(5,3)*((AVotingCutOffAgainst5/100)^3)*(1-(AVotingCutOffAgainst4/100))^2+0.5*comb(5,2)*((AVotingCutOffAgainst5/100)^2)*(1-(AVotingCutOffAgainst3/100)^5)
mean AVotingCutOffAgainst5
mean QualityTreatmentAgaN5
signrank QualityTreatmentAgaN5=0.880517
permtest1 QualityTreatmentAgaN5=0.880517
signrank  AVotingCutOffAgainst5=67.5
permtest1  AVotingCutOffAgainst5=67.5


/////////When Partisan Bias was Neutral and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral1=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesNeutral1=mean(MeanWTVNeutral1)
by ElectorateID, sort: gen AVotingCutOffNeutral1=AvergesNeutral1 if _n==1
gen QualityTreatmentNeuN1=1-0.5*(1-AVotingCutOffNeutral1/100)
mean AVotingCutOffNeutral1
mean QualityTreatmentNeuN1
signrank QualityTreatmentNeuN1=1
permtest1 QualityTreatmentNeuN1=1
signrank  AVotingCutOffNeutral1=100
permtest1  AVotingCutOffNeutral1=100

/////////When Partisan Bias was Neutral and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral2=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesNeutral2=mean(MeanWTVNeutral2)
by ElectorateID, sort: gen AVotingCutOffNeutral2=AvergesNeutral2 if _n==1
gen QualityTreatmentNeuN2=1-0.5*(1-AVotingCutOffNeutral2/100)^2
mean AVotingCutOffNeutral2
mean QualityTreatmentNeuN2
signrank QualityTreatmentNeuN2=0.959184
permtest1 QualityTreatmentNeuN2=0.959184
signrank  AVotingCutOffNeutral2=71.4
permtest1  AVotingCutOffNeutral2=71.4

/////////When Partisan Bias was Neutral and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral3=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesNeutral3=mean(MeanWTVNeutral3)
by ElectorateID, sort: gen AVotingCutOffNeutral3=AvergesNeutral3 if _n==1
gen QualityTreatmentNeuN3=1-0.5*(1-AVotingCutOffNeutral3/100)^3
mean AVotingCutOffNeutral3
mean QualityTreatmentNeuN3
signrank QualityTreatmentNeuN3=0.950269
permtest1 QualityTreatmentNeuN3=0.950269
signrank  AVotingCutOffNeutral3=53.7
permtest1  AVotingCutOffNeutral3=53.7

/////////When Partisan Bias was Neutral and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral4=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesNeutral4=mean(MeanWTVNeutral4)
by ElectorateID, sort: gen AVotingCutOffNeutral4=AvergesNeutral4 if _n==1
gen QualityTreatmentNeuN4=1-0.5*(1-AVotingCutOffNeutral4/100)^4
mean AVotingCutOffNeutral4
mean QualityTreatmentNeuN4
signrank QualityTreatmentNeuN4=0.950828
permtest1 QualityTreatmentNeuN4=0.950828
signrank  AVotingCutOffNeutral4=44
permtest1  AVotingCutOffNeutral4=44

/////////When Partisan Bias was Neutral and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral5=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesNeutral5=mean(MeanWTVNeutral5)
by ElectorateID, sort: gen AVotingCutOffNeutral5=AvergesNeutral5 if _n==1
gen QualityTreatmentNeuN5=1-0.5*(1-AVotingCutOffNeutral5/100)^5
mean AVotingCutOffNeutral5
mean QualityTreatmentNeuN5
signrank QualityTreatmentNeuN5=0.953074
permtest1 QualityTreatmentNeuN5=0.953074
signrank  AVotingCutOffNeutral5=37.7
permtest1  AVotingCutOffNeutral5=37.7


/////////When Partisan Bias was Supportive and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive1=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesSupportive1=mean(MeanWTVSupportive1)
by ElectorateID, sort: gen AVotingCutOffSupportive1=AvergesSupportive1 if _n==1
gen QualityTreatmentSuppN1=1
mean AVotingCutOffSupportive1
signrank AVotingCutOffSupportive1=0
permtest1 AVotingCutOffSupportive1=0


/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive2=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesSupportive2=mean(MeanWTVSupportive2)
by ElectorateID, sort: gen AVotingCutOffSupportive2=AvergesSupportive2 if _n==1
gen QualityTreatmentSuppN2=1
mean AVotingCutOffSupportive2
signrank AVotingCutOffSupportive2=0
permtest1 AVotingCutOffSupportive2=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive3=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesSupportive3=mean(MeanWTVSupportive3)
by ElectorateID, sort: gen AVotingCutOffSupportive3=AvergesSupportive3 if _n==1
gen QualityTreatmentSuppN3=1
mean AVotingCutOffSupportive3
signrank AVotingCutOffSupportive3=0
permtest1 AVotingCutOffSupportive3=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive4=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesSupportive4=mean(MeanWTVSupportive4)
by ElectorateID, sort: gen AVotingCutOffSupportive4=AvergesSupportive4 if _n==1
gen QualityTreatmentSuppN4=1
mean AVotingCutOffSupportive4
signrank AVotingCutOffSupportive4=0
permtest1 AVotingCutOffSupportive4=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive5=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesSupportive5=mean(MeanWTVSupportive5)
by ElectorateID, sort: gen AVotingCutOffSupportive5=AvergesSupportive5 if _n==1
gen QualityTreatmentSuppN5=1
mean AVotingCutOffSupportive5
signrank AVotingCutOffSupportive5=0
permtest1 AVotingCutOffSupportive5=0

restore



preserve
*Now we focus on the behavior of expert voters in the Control Group
drop if Expertise==0
drop if Treatment=="TreatmentGroup"

//////////      When the partisan bias is Against      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst=mean(Willingness2Vote) if Against==1
by ElectorateID, sort: egen AvergesAgainst=mean(MeanWTVAgainst)
by ElectorateID, sort: gen AVotingCutOffAgainst=AvergesAgainst if _n==1
gen QualityTreatmentAga=comb(5,3)*(0.7*(AVotingCutOffAgainst/100))^3*(1-(0.7*(AVotingCutOffAgainst/100)))^2+comb(5,4)*(0.7*(AVotingCutOffAgainst/100))^4*(1-(0.7*(AVotingCutOffAgainst/100)))^1+comb(5,5)*(0.7*(AVotingCutOffAgainst/100))^5+0.5*comb(5,2)*((0.7*(AVotingCutOffAgainst/100))^2)*(1-(0.7*(AVotingCutOffAgainst/100)))^3
mean AVotingCutOffAgainst
mean QualityTreatmentAga
signrank QualityTreatmentAga=0.878986
permtest1 QualityTreatmentAga=0.878986
signrank  AVotingCutOffAgainst=96.2
permtest1  AVotingCutOffAgainst=96.2

//////////      When the partisan bias is Neutral      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral=mean(Willingness2Vote) if Neutral==1
by ElectorateID, sort: egen AvergesNeutral=mean(MeanWTVNeutral)
by ElectorateID, sort: gen AVotingCutOffNeutral=AvergesNeutral if _n==1
gen QualityTreatmentNeu=comb(5,1)*(0.7*(AVotingCutOffNeutral/100))*(1-(0.7*(AVotingCutOffNeutral/100)))^4+comb(5,2)*(0.7*(AVotingCutOffNeutral/100))^2*(1-(0.7*(AVotingCutOffNeutral/100)))^3+comb(5,3)*(0.7*(AVotingCutOffNeutral/100))^3*(1-(0.7*(AVotingCutOffNeutral/100)))^2+comb(5,4)*(0.7*(AVotingCutOffNeutral/100))^4*(1-(0.7*(AVotingCutOffNeutral/100)))^1+comb(5,5)*(0.7*(AVotingCutOffNeutral/100))^5+0.5*comb(5,0)*((0.7*(AVotingCutOffNeutral/100))^0)*(1-(0.7*(AVotingCutOffNeutral/100)))^5
mean AVotingCutOffNeutral
mean QualityTreatmentNeu
signrank QualityTreatmentNeu=0.93614
permtest1 QualityTreatmentNeu=0.93614
signrank  AVotingCutOffNeutral=48.2
permtest1  AVotingCutOffNeutral=48.2


//////////      When the partisan bias is Supportive      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive=mean(Willingness2Vote) if Supportive==1
by ElectorateID, sort: egen AvergesSupportive=mean(MeanWTVSupportive)
by ElectorateID, sort: gen AVotingCutOffSupportive=AvergesSupportive if _n==1
gen QualityTreatmentSupp=1
mean AVotingCutOffSupportive

signrank  AVotingCutOffSupportive=0
permtest1  AVotingCutOffSupportive=0

restore


//////////////////////////////////////////////////////////////////////////
////////////////                Figure 7                 /////////////////
//////////////////////////////////////////////////////////////////////////
preserve
//Based on the information elicted above, we make Figure 7 using the following codes//

clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure7WTV") firstrow
twoway (bar Mean Position if Treatment=="Control"&Category=="Supportive",  name(Supportive,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Supportive",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Supportive",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Supportive",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Supportive",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Supportive",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Supportive",mcolor(blue) msymbol(Sh)),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Willingness to vote") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 ) ring(0) position(1) symxsize(Medium) keygap(tiny)  col(1) label(1 "Control (Mean)") label(2 "Treatment,N=2") label(3 "Treatment,N=3") label(4 "Treatment,N=4") label(5 "Treatment,N=5")  label(6 "Optimal Cutoff Cost")) title("Supportive",color(black))  graphregion(color(white)) plotregion(color(white))    
twoway (bar Mean Position if Treatment=="Control"&Category=="Neutral",  name(Neutral,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Neutral",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Neutral",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Neutral",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Neutral",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Neutral",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Neutral",mcolor(blue) msymbol(Sh)),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Willingness to vote") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 ) ring(0) position(1) symxsize(Medium) keygap(tiny)  col(1) label(1 "Control (Mean)") label(2 "Treatment,N=2") label(3 "Treatment,N=3") label(4 "Treatment,N=4") label(5 "Treatment,N=5")  label(6 "Optimal Cutoff Cost")) title("Neutral",color(black))  graphregion(color(white)) plotregion(color(white))    
twoway (bar Mean Position if Treatment=="Control"&Category=="Against",  name(Against,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Against",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Against",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Against",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Against",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Against",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Against",mcolor(blue) msymbol(Sh)),  ylabel(0 (20) 100,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Willingness to vote") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 7) ring(0) position(1) symxsize(3) keygap(tiny)  col(4) label(1 "Control Group") label(2 "Treatment,N=1") label(3 "Treatment,N=2") label(4 "Treatment,N=3") label(5 "Treatment,N=4") label(6 "Treatment,N=5") label(7 "Planner's Prescription") size(2)) title("Against",color(black))  graphregion(color(white)) plotregion(color(white))    


clear
import excel "D:\FiguresReplications.xlsx",  sheet("Figure7Quality") firstrow
twoway (bar Mean Position if Treatment=="Control"&Category=="Supportive",  name(Supportive1,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Supportive",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Supportive",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Supportive",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Supportive",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Supportive",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Supportive",mcolor(blue) msymbol(Sh)),  ylabel(0 (0.2) 1,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Quality of Democratic Choice") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 ) ring(0) position(1) symxsize(Medium) keygap(tiny)  col(1) label(1 "Control (Mean)") label(2 "Treatment,N=2") label(3 "Treatment,N=3") label(4 "Treatment,N=4") label(5 "Treatment,N=5")  label(6 "Optimal Cutoff Cost")) title("Supportive",color(black))  graphregion(color(white)) plotregion(color(white))    
twoway (bar Mean Position if Treatment=="Control"&Category=="Neutral",  name(Neutral1,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Neutral",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Neutral",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Neutral",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Neutral",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Neutral",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Neutral",mcolor(blue) msymbol(Sh)),  ylabel(0 (0.2) 1,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Quality of Democratic Choice") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 ) ring(0) position(1) symxsize(Medium) keygap(tiny)  col(1) label(1 "Control (Mean)") label(2 "Treatment,N=2") label(3 "Treatment,N=3") label(4 "Treatment,N=4") label(5 "Treatment,N=5")  label(6 "Optimal Cutoff Cost")) title("Neutral",color(black))  graphregion(color(white)) plotregion(color(white))    
twoway (bar Mean Position if Treatment=="Control"&Category=="Against",  name(Against1,replace) fcolor(black) bcolor(gs10) lwidth(0.1) xaxis(1 2) yaxis(1 2) )||(bar Mean Position if Treatment=="T1"&Category=="Against",  fcolor(gs2) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T2"&Category=="Against",  fcolor(gs7) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T3"&Category=="Against",  fcolor(gs10) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T4"&Category=="Against",  fcolor(gs14) bcolor(gs10) lwidth(0.1))||(bar Mean Position if Treatment=="T5"&Category=="Against",  fcolor(white) bcolor(gs10) lwidth(0.1))||(scatter Prediction Position if Category=="Against",mcolor(blue) msymbol(Sh)),  ylabel(0 (0.2) 1,nogrid) ylabel("",axis(2)) xlabel("") xlabel("",axis(2)) ytitle("Quality of Democratic Choice") ytitle("",axis(2)) xtitle("") xtitle("",axis(2))     legend(region(lcolor(white))  order(1 2 3 4 5 6 ) ring(0) position(1) symxsize(Medium) keygap(tiny)  col(5) label(1 "Control Group") label(2 "Treatment,N=2") label(3 "Treatment,N=3") label(4 "Treatment,N=4") label(5 "Treatment,N=5")  label(6 "Optimal Cutoff Cost")) title("Against",color(black))  graphregion(color(white)) plotregion(color(white))    
grc1leg Against Neutral Supportive Against1 Neutral1 Supportive1, name(Figure7,replace) col(3) graphregion(color(white)) plotregion(color(white)) position(6) ring(1) note("Note: The vertical axis of figures in the first row shows the willingness to vote. The vertical axis of figures" "in the second row shows the quality of democratic choice.")
graph display Figure7, xsize(8) ysize(6)
graph export "D:\Figure7.pdf", as(pdf) replace
restore



********************************************************************************
********************************************************************************
********************************************************************************


//In the following, we report the statistical analysis, figures, and tables of Online Appendix//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix A                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
preserve
tab State
tab Expertise
tab Supportive if Treatment=="ControlGroup"
tab Neutral if Treatment=="ControlGroup"
tab Against if Treatment=="ControlGroup"
tab Supportive if Treatment=="TreatmentGroup"
tab Neutral if Treatment=="TreatmentGroup"
tab Against if Treatment=="TreatmentGroup"
restore
//////////////////////////////////////////////////////////////////////////
////////////////                Figure A1                 /////////////////
//////////////////////////////////////////////////////////////////////////
preserve
by ElectionID, sort: egen Informedness=mean(Expertise)
gen SocialKnowledge=0
replace SocialKnowledge=1 if Treatment=="TreatmentGroup"
collapse Expertise Period SocialKnowledge Informedness,by(ElectionID)
by SocialKnowledge Period, sort: egen Informed=mean(Informedness) 
by SocialKnowledge Period, sort: egen InformedSD=sd(Informedness) 
collapse Informed InformedSD,by(SocialKnowledge Period)
gen SE=InformedSD/(sqrt(6))
gen Low95CI=Informed-1.96*SE
gen High95CI=Informed+1.96*SE
tw (rspike High95CI Low95CI Period if SocialKnowledge==1, lcolor(gs12) xaxis(1 2) yaxis(1 2))||(scatter Informed Period if SocialKnowledge==1,name(withSK,replace) mcolor(gs6)), graphregion(color(white)) plotregion(color(white)) bgcolor(white)  ylabel(0 0.5 0.7 1,nogrid) ylabel("",axis(2)) xlabel("",axis(2)) ytitle("") xtitle("Period",axis(1)) xtitle("",axis(2)) title("Treatment Group",color(black)) legend(region(lcolor(white)) symxsize(Medium) keygap(tiny)order (2 1) label (2 "Mean") label( 1 "95% CI") col(2) position (6) ring(0))  yline(0.7)
tw (rspike High95CI Low95CI Period if SocialKnowledge==0, lcolor(gs12) xaxis(1 2) yaxis(1 2))||(scatter Informed Period if SocialKnowledge==0,name(withoutSK,replace) mcolor(gs6)), graphregion(color(white)) plotregion(color(white)) bgcolor(white)  ylabel(0 0.5 0.7 1,nogrid) ylabel("",axis(2)) xlabel("",axis(2)) ytitle("") xtitle("Period",axis(1)) xtitle("",axis(2)) title("Control Group",color(black)) legend(region(lcolor(white)) symxsize(Medium) keygap(tiny)order (2 1) label (2 "Mean") label( 1 "95% CI") col(2) position (6) ring(0))  yline(0.7)
grc1leg withoutSK withSK, name(FigureA1,replace) l1("Proportion of Expert Voters") graphregion(color(white)) plotregion(color(white)) row(2)
graph display FigureA1, xsize(12) ysize(8)
graph export "D:\FigureA1.pdf", as(pdf) replace
restore

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix B                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
preserve
*First, we calculate the quality of democratic choice in each election period
gen RightChoice=0 if Expertise==1&Vote!=State&Willingness2Vote>=RandVotingCost
replace RightChoice=1 if Vote==State&Expertise==1&Willingness2Vote>=RandVotingCost
gen WrongChoice=0 if Expertise==1&Vote==State&Willingness2Vote>=RandVotingCost
replace WrongChoice=1 if Vote!=State&Vote<3&Expertise==1&Willingness2Vote>=RandVotingCost
by ElectionID, sort: egen NRightChoice=total(RightChoice)
by ElectionID, sort: egen NWrongChoice=total(WrongChoice)
gen SumRightVotes=NRightChoice+2 if Supportive==1
replace SumRightVotes=NRightChoice+1 if Neutral==1
replace SumRightVotes=NRightChoice if Against==1
gen SumWrongVotes=NWrongChoice+2 if Against==1
replace SumWrongVotes=NWrongChoice+1 if Neutral==1
replace SumWrongVotes=NWrongChoice if Supportive==1
gen ProbRight=1 if SumRightVotes>SumWrongVotes
replace ProbRight=0 if SumRightVotes<SumWrongVotes
replace ProbRight=0.5 if SumRightVotes==SumWrongVotes
sort ElectionID
by ElectionID: gen Quality=ProbRight if _n==1

//////////////////////////////////////////////////////////////////////
/////////                     Table A1                        ////////
//////////////////////////////////////////////////////////////////////
//Then we run OLS regressions to check if the quality of democratic choice significantly changes over time// 
gen TreatmentDummy=0
replace TreatmentDummy=1 if Treatment=="TreatmentGroup"
reg Quality TreatmentDummy,cluster(ElectorateID)
outreg2 using Table_A1.doc,  replace  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Quality TreatmentDummy Period,cluster(ElectorateID)
outreg2 using Table_A1.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix C                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                     Table A2                        ////////
//////////////////////////////////////////////////////////////////////
gen TreatmentAgainst=TreatmentDummy*Against
gen TreatmentNeutral=TreatmentDummy*Neutral

reg Willingness2Vote Expertise,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  replace  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote TreatmentDummy if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote Period if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote Against Neutral if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote TreatmentDummy Period Against Neutral if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote TreatmentDummy Period Against Neutral TreatmentAgainst TreatmentNeutral if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Willingness2Vote TreatmentDummy Period Against Neutral TreatmentAgainst TreatmentNeutral Age Female CRTScore if Expertise==1,cluster(GlobalSubjectID)
outreg2 using TableA2.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix D                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                     Table A3                        ////////
//////////////////////////////////////////////////////////////////////
reg Quality Period if Treatment=="ControlGroup",cluster(ElectorateID)
outreg2 using TableA3.doc,  replace  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
reg Quality Period if Treatment=="TreatmentGroup",cluster(ElectorateID)
outreg2 using TableA3.doc,  append  dec(3) alpha(0.01, 0.05, 0.10) symbol(***,**,*)
restore


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix G                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                     Table A4                        ////////
//////////////////////////////////////////////////////////////////////
//In Table A4, we report theoretical analysis of Pivotal Voting Models//
//The equilibrium point predictions and how they are calculated and detailed in Online Appendix G//
//Specifically, the point predictions for Against when Expertise is Unknown is 27.55, 
//which is reported on page 16 of Online Appendix.
//The point predictions for Against and Supportive when Expertise is Unknown is 23.98 and 0, respectively, 
//which is reported on page 17 of Online Appendix.
//The point predictions for the average willingness to vote when Expertise is Unknown is 17.18, 
//which is reported on page 17 of Online Appendix.
//When Expertise is Known, when the partisan bias is Against, the point predictions are 
//reported by the number of realized expert voters on page 18 of Online Appendix.
//When Expertise is Known, when the partisan bias is Neutral or Supportive, the point predictions are 
//reported by the number of realized expert voters on page 19 of Online Appendix.
//The point predictions for the average willingness to vote when Expertise is Known is 7.78, 
//which is reported on page 20 of Online Appendix.

//The experimental results are based on the statistics derived by this do file, and copied from Lines 600-787
preserve
*We first focus on the behavior of expert voters in the Treatment Group
drop if Expertise==0
drop if Treatment=="ControlGroup"


/////////When Partisan Bias was Against and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst1=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesAgainst1=mean(MeanWTVAgainst1)
by ElectorateID, sort: gen AVotingCutOffAgainst1=AvergesAgainst1 if _n==1
gen QualityTreatmentAgaN1=0
mean AVotingCutOffAgainst1
mean QualityTreatmentAgaN1
signrank  AVotingCutOffAgainst1=0
permtest1  AVotingCutOffAgainst1=0

/////////When Partisan Bias was Against and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst2=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesAgainst2=mean(MeanWTVAgainst2)
by ElectorateID, sort: gen AVotingCutOffAgainst2=AvergesAgainst2 if _n==1
gen QualityTreatmentAgaN2=(AVotingCutOffAgainst2/100)^2
mean AVotingCutOffAgainst2
mean QualityTreatmentAgaN2
signrank QualityTreatmentAgaN2=1
permtest1 QualityTreatmentAgaN2=1
signrank  AVotingCutOffAgainst2=100
permtest1  AVotingCutOffAgainst2=100

/////////When Partisan Bias was Against and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst3=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesAgainst3=mean(MeanWTVAgainst3)
by ElectorateID, sort: gen AVotingCutOffAgainst3=AvergesAgainst3 if _n==1
gen QualityTreatmentAgaN3=comb(3,3)*(AVotingCutOffAgainst3/100)^3+0.5*comb(3,2)*((AVotingCutOffAgainst3/100)^2)*(1-(AVotingCutOffAgainst3/100))
mean AVotingCutOffAgainst3
mean QualityTreatmentAgaN3
signrank QualityTreatmentAgaN3=1
permtest1 QualityTreatmentAgaN3=1
signrank  AVotingCutOffAgainst3=100
permtest1  AVotingCutOffAgainst3=100

/////////When Partisan Bias was Against and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst4=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesAgainst4=mean(MeanWTVAgainst4)
by ElectorateID, sort: gen AVotingCutOffAgainst4=AvergesAgainst4 if _n==1
gen QualityTreatmentAgaN4=comb(4,3)*((AVotingCutOffAgainst4/100)^3)*(1-(AVotingCutOffAgainst4/100))+0.5*comb(4,2)*((AVotingCutOffAgainst4/100)^2)*(1-(AVotingCutOffAgainst3/100)^2)
mean AVotingCutOffAgainst4
mean QualityTreatmentAgaN4
signrank QualityTreatmentAgaN4=0.951638
permtest1 QualityTreatmentAgaN4=0.951638
signrank  AVotingCutOffAgainst4=86.7
permtest1  AVotingCutOffAgainst4=86.7

/////////When Partisan Bias was Against and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst5=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesAgainst5=mean(MeanWTVAgainst5)
by ElectorateID, sort: gen AVotingCutOffAgainst5=AvergesAgainst5 if _n==1
gen QualityTreatmentAgaN5=comb(5,3)*((AVotingCutOffAgainst5/100)^3)*(1-(AVotingCutOffAgainst4/100))^2+0.5*comb(5,2)*((AVotingCutOffAgainst5/100)^2)*(1-(AVotingCutOffAgainst3/100)^5)
mean AVotingCutOffAgainst5
mean QualityTreatmentAgaN5
signrank QualityTreatmentAgaN5=0.880517
permtest1 QualityTreatmentAgaN5=0.880517
signrank  AVotingCutOffAgainst5=67.5
permtest1  AVotingCutOffAgainst5=67.5


/////////When Partisan Bias was Neutral and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral1=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesNeutral1=mean(MeanWTVNeutral1)
by ElectorateID, sort: gen AVotingCutOffNeutral1=AvergesNeutral1 if _n==1
gen QualityTreatmentNeuN1=1-0.5*(1-AVotingCutOffNeutral1/100)
mean AVotingCutOffNeutral1
mean QualityTreatmentNeuN1
signrank QualityTreatmentNeuN1=1
permtest1 QualityTreatmentNeuN1=1
signrank  AVotingCutOffNeutral1=100
permtest1  AVotingCutOffNeutral1=100

/////////When Partisan Bias was Neutral and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral2=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesNeutral2=mean(MeanWTVNeutral2)
by ElectorateID, sort: gen AVotingCutOffNeutral2=AvergesNeutral2 if _n==1
gen QualityTreatmentNeuN2=1-0.5*(1-AVotingCutOffNeutral2/100)^2
mean AVotingCutOffNeutral2
mean QualityTreatmentNeuN2
signrank QualityTreatmentNeuN2=0.959184
permtest1 QualityTreatmentNeuN2=0.959184
signrank  AVotingCutOffNeutral2=71.4
permtest1  AVotingCutOffNeutral2=71.4

/////////When Partisan Bias was Neutral and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral3=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesNeutral3=mean(MeanWTVNeutral3)
by ElectorateID, sort: gen AVotingCutOffNeutral3=AvergesNeutral3 if _n==1
gen QualityTreatmentNeuN3=1-0.5*(1-AVotingCutOffNeutral3/100)^3
mean AVotingCutOffNeutral3
mean QualityTreatmentNeuN3
signrank QualityTreatmentNeuN3=0.950269
permtest1 QualityTreatmentNeuN3=0.950269
signrank  AVotingCutOffNeutral3=53.7
permtest1  AVotingCutOffNeutral3=53.7

/////////When Partisan Bias was Neutral and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral4=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesNeutral4=mean(MeanWTVNeutral4)
by ElectorateID, sort: gen AVotingCutOffNeutral4=AvergesNeutral4 if _n==1
gen QualityTreatmentNeuN4=1-0.5*(1-AVotingCutOffNeutral4/100)^4
mean AVotingCutOffNeutral4
mean QualityTreatmentNeuN4
signrank QualityTreatmentNeuN4=0.950828
permtest1 QualityTreatmentNeuN4=0.950828
signrank  AVotingCutOffNeutral4=44
permtest1  AVotingCutOffNeutral4=44

/////////When Partisan Bias was Neutral and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral5=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesNeutral5=mean(MeanWTVNeutral5)
by ElectorateID, sort: gen AVotingCutOffNeutral5=AvergesNeutral5 if _n==1
gen QualityTreatmentNeuN5=1-0.5*(1-AVotingCutOffNeutral5/100)^5
mean AVotingCutOffNeutral5
mean QualityTreatmentNeuN5
signrank QualityTreatmentNeuN5=0.953074
permtest1 QualityTreatmentNeuN5=0.953074
signrank  AVotingCutOffNeutral5=37.7
permtest1  AVotingCutOffNeutral5=37.7


/////////When Partisan Bias was Supportive and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive1=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesSupportive1=mean(MeanWTVSupportive1)
by ElectorateID, sort: gen AVotingCutOffSupportive1=AvergesSupportive1 if _n==1
gen QualityTreatmentSuppN1=1
mean AVotingCutOffSupportive1
signrank AVotingCutOffSupportive1=0
permtest1 AVotingCutOffSupportive1=0


/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive2=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesSupportive2=mean(MeanWTVSupportive2)
by ElectorateID, sort: gen AVotingCutOffSupportive2=AvergesSupportive2 if _n==1
gen QualityTreatmentSuppN2=1
mean AVotingCutOffSupportive2
signrank AVotingCutOffSupportive2=0
permtest1 AVotingCutOffSupportive2=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive3=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesSupportive3=mean(MeanWTVSupportive3)
by ElectorateID, sort: gen AVotingCutOffSupportive3=AvergesSupportive3 if _n==1
gen QualityTreatmentSuppN3=1
mean AVotingCutOffSupportive3
signrank AVotingCutOffSupportive3=0
permtest1 AVotingCutOffSupportive3=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive4=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesSupportive4=mean(MeanWTVSupportive4)
by ElectorateID, sort: gen AVotingCutOffSupportive4=AvergesSupportive4 if _n==1
gen QualityTreatmentSuppN4=1
mean AVotingCutOffSupportive4
signrank AVotingCutOffSupportive4=0
permtest1 AVotingCutOffSupportive4=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive5=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesSupportive5=mean(MeanWTVSupportive5)
by ElectorateID, sort: gen AVotingCutOffSupportive5=AvergesSupportive5 if _n==1
gen QualityTreatmentSuppN5=1
mean AVotingCutOffSupportive5
signrank AVotingCutOffSupportive5=0
permtest1 AVotingCutOffSupportive5=0

restore






//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix H                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
preserve
clear
import excel "D:\FiguresReplications.xlsx",  sheet("FigureA234") firstrow
//////////////////////////////////////////////////////////////////////
/////////                     Figure A2                       ////////
//////////////////////////////////////////////////////////////////////
tw (line c mu if Partisan=="Against"&Group=="Control", lcolor(gs10) lpattern(dash))||(line c mu if Partisan=="Neutral"&Group=="Control",lcolor(gs10) lwidth(thick))||(line c mu if Partisan=="Supportive"&Group=="Control",lcolor(black)), ylabel(0 (0.1) 0.6,nogrid) ytitle("Logit-QRE" "cutoff willingness to vote") xtitle("{&mu} (noise parameter)") graphregion(color(white)) plotregion(color(white)) bgcolor(white) legend(region(lcolor(white)) order (1 2 3) symxsize(Medium) keygap(tiny) label (1 "Against") label( 2 "Neutral") label ( 3 "Supportive") row(3) position (5) ring(0))
graph export "D:\FigureA2.pdf", as(pdf) replace
//////////////////////////////////////////////////////////////////////
/////////                     Figure A3                       ////////
//////////////////////////////////////////////////////////////////////
tw (line c mu if Partisan=="Against"&Group=="Treatment", lcolor(gs10) lpattern(dash))||(line c mu if Partisan=="Neutral"&Group=="Treatment",lcolor(gs10) lwidth(thick))||(line c mu if Partisan=="Supportive"&Group=="Treatment",lcolor(black)), ylabel(0 (0.1) 0.4,nogrid) ytitle("Logit-QRE" "cutoff willingness to vote") xtitle("{&mu} (noise parameter)") graphregion(color(white)) plotregion(color(white)) bgcolor(white) legend(region(lcolor(white)) order (1 2 3) symxsize(Medium) keygap(tiny) label (1 "Against") label( 2 "Neutral") label ( 3 "Supportive") row(3) position (5) ring(0))
graph export "D:\FigureA3.pdf", as(pdf) replace
//////////////////////////////////////////////////////////////////////
/////////                     Figure A4                       ////////
//////////////////////////////////////////////////////////////////////
tw (line c mu if Partisan=="Against"&Group=="Control", name(Against,replace) lcolor(gs10) lpattern(dash) xaxis(1 2) yaxis(1 2))||(line c mu if Partisan=="Against"&Group=="Treatment", lcolor(blue) lpattern(dash) lwidth(thick)), ylabel(0 (0.1) 0.6,nogrid axis(1)) ylabel("",nogrid axis(2)) xlabel("",nogrid axis(2)) ytitle("Logit-QRE" "cutoff willingness to vote") xtitle("{&mu} (noise parameter)") xtitle("",axis(2)) ytitle("",axis(2)) graphregion(color(white)) plotregion(color(white)) bgcolor(white) title("Against",color(black)) legend(region(lcolor(white)) order (1 2) symxsize(5) keygap(tiny) label (1 "Control") label( 2 "Treatment") row(2) position (5) ring(0))
tw (line c mu if Partisan=="Neutral"&Group=="Control", name(Neutral,replace) lcolor(gs10) lpattern(dash) xaxis(1 2) yaxis(1 2))||(line c mu if Partisan=="Neutral"&Group=="Treatment", lcolor(blue) lpattern(dash) lwidth(thick)), ylabel(0 (0.1) 0.6,nogrid axis(1)) ylabel("",nogrid axis(2)) xlabel("",nogrid axis(2)) ytitle("") xtitle("{&mu} (noise parameter)") xtitle("",axis(2)) ytitle("",axis(2)) graphregion(color(white)) plotregion(color(white)) bgcolor(white) title("Neutral",color(black)) legend(region(lcolor(white)) order (1 2) symxsize(5) keygap(tiny) label (1 "Control") label( 2 "Treatment") row(2) position (5) ring(0))
tw (line c mu if Partisan=="Supportive"&Group=="Control", name(Supportive,replace) lcolor(gs10) lpattern(dash) xaxis(1 2) yaxis(1 2))||(line c mu if Partisan=="Supportive"&Group=="Treatment", lcolor(blue) lpattern(dash) lwidth(thick)), ylabel(0 (0.1) 0.6,nogrid axis(1)) ylabel("",nogrid axis(2)) xlabel("",nogrid axis(2)) ytitle("") xtitle("{&mu} (noise parameter)") xtitle("",axis(2)) ytitle("",axis(2)) graphregion(color(white)) plotregion(color(white)) bgcolor(white) title("Supportive",color(black)) legend(region(lcolor(white)) order (1 2) symxsize(5) keygap(tiny) label (1 "Control") label( 2 "Treatment") row(2) position (5) ring(0))
graph combine Against Neutral Supportive, name(FigureA4,replace) row(1) graphregion(color(white)) plotregion(color(white))
graph display FigureA4, xsize(12) ysize(6)
graph export "D:\FigureA4.pdf", as(pdf) replace
restore
//////////////////////////////////////////////////////////////////////
/////////                     Table A5                        ////////
//////////////////////////////////////////////////////////////////////
//In Table A5, we report the theoretical analysis of Quantal Response Equilibrium//
//For the Control Group//
//The calculations used the symmetric Bayesian Nash equilibirum willingness to 
//vote equations defined in line 20 on page 16 of Online Appendix, and plug in that equiation to 
//to the equation detailed in lines 17-20 on page 22 of Online Appendix to 
//calculate the willingness to vote of Control Group when partisan bias is against//
//The calculations used the symmetric Bayesian Nash equilibirum willingness to 
//vote equations defined in line 2 on page 17 of Online Appendix, and plug in that equiation to 
//to the equation detailed in lines 17-20 on page 22 of Online Appendix to 
//calculate the willingness to vote of Control Group when partisan bias is neutral//
//We manually set WTV=0, which is derived from the analysis in lines 3-5 on page 17 of Online Appendix, 
//and plug it to the equation detailed in lines 17-20 on page 22 of Online Appendix to 
//calculate the willingness to vote of Control Group when partisan bias is supportive//
//We manually averaged the point predictions of Against, Neutral, and Supportive and got the average willingness to vote in Control Group is 39.2

//For the Treatment Group//
//The calculations used the symmetric Bayesian Nash equilibirum willingness to 
//vote equations defined in lines 6-7 on page 18 of Online Appendix, and plug in that equiation to 
//to the equation detailed in lines 17-20 on page 22 of Online Appendix to 
//calculate the willingness to vote of Treatment Group//
//As noted in line 9 on page 20 of Online Appendix, in the calculations of point predictions, we set d=s=0
//We manually averaged the point predictions of Against, Neutral, and Supportive and got the average willingness to vote in Treatment Group is 26.6.


//The experimental results mentioned in the table are based on the statistics derived by this do file, copied from Lines 108-161
*When partisan bias is against
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Against==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Against==1
preserve
drop if Expertise==0
drop if Against!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore



*When partisan bias is neutral
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Neutral==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Neutral==1
preserve
drop if Expertise==0
drop if Neutral!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore



*When partisan bias is supportive
mean Willingness2Vote if Treatment=="ControlGroup"&Expertise==1&Supportive==1
mean Willingness2Vote if Treatment=="TreatmentGroup"&Expertise==1&Supportive==1
preserve
drop if Expertise==0
drop if Supportive!=1
mean Willingness2Vote if Treatment=="ControlGroup"
mean Willingness2Vote if Treatment=="TreatmentGroup"

sort GlobalSubjectID
by GlobalSubjectID, sort: egen MeanWTV=mean(Willingness2Vote)
by GlobalSubjectID, sort: gen AVotingCutOff=MeanWTV if _n==1

ranksum AVotingCutOff,by(Treatment)
permtest2 AVotingCutOff,by(FPTestIndicator)
restore

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                Online Appendix I                    ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////                     Table A6                        ////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//In Table A6, we report the theoretical analysis of Utilitarian Welfare//
//The utilitarian planner's symmetric cost vote cutoff prescription are calculated and detailed in Online Appendix I//
//Specifically, in line 8 on page 29 of Online Appendix, 
//we report point predictions of willingness to vote when partisan bias is Supportive in Control Group
//In lines 9-19 on page 29 of Online Appendix, 
//we report how we manually calculate point predictions of willingness to vote when partisan bias is Neutral in Control Group
//In line 20 on page 29 and lines 1-5 on page 30 of Online Appendix, 
//we report how we manually calculate point predictions of willingness to vote when partisan bias is Against in Control Group.
//In line 5 on page 26 of Online Appendix, 
//we report how we manually calculate point predictions of willingness to vote when partisan bias is Supportive in Treatment Group
//In lines 6-19 on page 26 and lines 1-14 on page 27 of Online Appendix, 
//we report how we manually calculate point predictions of willingness to vote when partisan bias is Neutral in Treatment Group
//In lines 20-26 on page 27 and lines 1-16 on page 28 and lines 1-4 on page 29 of Online Appendix, 
//we report how we manually calculate point predictions of willingness to vote when partisan bias is Against in Treatment Group



//////////////////////////////////////////////////////////////////////
/////////                      Table A7                       ////////
//////////////////////////////////////////////////////////////////////
//In our experiment, the number of expert voters was exogenously, randomly, and independently determined by the computer.  
//Recall that in the Treatment Group, subjects were told the realized number of expert voters. 
//While on average 70% of voters are expert voters, in specific voting round, the number of expert voters could be 1, 2, 3, 4, or 5. 
//Hence, the realized number of expert voters is denoted as M=1, M=2, M=3, M=4, and M=5 in the Online Appendix I and in Table A7. 
//However, in the Control Group, subjects were not told the realized number of expert voters. We thus only report the average effects in the column of Control Group.
//We use both Mann-Whiney sign-rank test and the exact Fisher-Pitman permutation test 
//to examine whether the experimental observations are different from the utilitarian 
//planners' prescription. The numbers reported in Table A7 are p-values of statistical tests. 
//For the Treatment Group, the p-values are reported by the number of exogenously realized 
//expert voters and the type of statistical tests. For the Control Group, 
//the p-values are reported by the type of statistical tests.

//We use the electorate averages as the unit of independent observation in the statistical analysis. 
//We have a total of 12 electorates in the Control Group and 12 electorates in the Treatment Group. 
//In the Control Group, since we pooled the average effects together in the analysis, the number of observations is 12. 
//In the Treatment Group, since we break down the analysis by the realized number of expert voters, 
//the number of observations is reported by the realization of parameters in our experiments. 
//The setting of the experiment is that in an electorate of 5 voters about 70% of voters are expert voters, 
//which explains there are more observations when M=3 and M=4 as compared to when M=1, M=2, and M=5.
//We performed statistical tests of both voters' willingness to vote and the quality 
//of democratic choice and report these results in Panel A and Panel B of Table A7, respectively. 
//The statistical results are reported by the level of partisan bias in each panel.
//In Table A7, the statistics are derived from the analysis of this do file codes, copied from Lines 595-834. 
//Using Lines 617-628 as an illustrative example. 
//The codes in these lines derive the statistical results for M=2 when the partisan bias is against. 
//At the electorate level, there are 8 observations. For the comparison between 
//observed willingness to vote and point predictions, the p-value of the two-sided 
//Mann-Whiney sign-rank is 0.0116, and the p-value of the two-sided exact Fisher-Pitman permutation test is 0.0078. 
//These p-values are reported in Panel A, Against, M=2. For the comparisons between the observed quality of 
//democratic choice and point predictions, the p-value of the two-sided Mann-Whiney sign-rank is 0.0116, 
//and the p-value of the two-sided exact Fisher-Pitman permutation test is 0.0078. 
//These p-values are reported in Panel B, Against, M=2. 

preserve
*We first focus on the behavior of expert voters in the Treatment Group
drop if Expertise==0
drop if Treatment=="ControlGroup"


/////////When Partisan Bias was Against and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst1=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesAgainst1=mean(MeanWTVAgainst1)
by ElectorateID, sort: gen AVotingCutOffAgainst1=AvergesAgainst1 if _n==1
gen QualityTreatmentAgaN1=0
mean AVotingCutOffAgainst1
mean QualityTreatmentAgaN1
signrank  AVotingCutOffAgainst1=0
permtest1  AVotingCutOffAgainst1=0

/////////When Partisan Bias was Against and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst2=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesAgainst2=mean(MeanWTVAgainst2)
by ElectorateID, sort: gen AVotingCutOffAgainst2=AvergesAgainst2 if _n==1
gen QualityTreatmentAgaN2=(AVotingCutOffAgainst2/100)^2
mean AVotingCutOffAgainst2
mean QualityTreatmentAgaN2
signrank QualityTreatmentAgaN2=1
permtest1 QualityTreatmentAgaN2=1
signrank  AVotingCutOffAgainst2=100
permtest1  AVotingCutOffAgainst2=100

/////////When Partisan Bias was Against and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst3=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesAgainst3=mean(MeanWTVAgainst3)
by ElectorateID, sort: gen AVotingCutOffAgainst3=AvergesAgainst3 if _n==1
gen QualityTreatmentAgaN3=comb(3,3)*(AVotingCutOffAgainst3/100)^3+0.5*comb(3,2)*((AVotingCutOffAgainst3/100)^2)*(1-(AVotingCutOffAgainst3/100))
mean AVotingCutOffAgainst3
mean QualityTreatmentAgaN3
signrank QualityTreatmentAgaN3=1
permtest1 QualityTreatmentAgaN3=1
signrank  AVotingCutOffAgainst3=100
permtest1  AVotingCutOffAgainst3=100

/////////When Partisan Bias was Against and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst4=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesAgainst4=mean(MeanWTVAgainst4)
by ElectorateID, sort: gen AVotingCutOffAgainst4=AvergesAgainst4 if _n==1
gen QualityTreatmentAgaN4=comb(4,3)*((AVotingCutOffAgainst4/100)^3)*(1-(AVotingCutOffAgainst4/100))+0.5*comb(4,2)*((AVotingCutOffAgainst4/100)^2)*(1-(AVotingCutOffAgainst3/100)^2)
mean AVotingCutOffAgainst4
mean QualityTreatmentAgaN4
signrank QualityTreatmentAgaN4=0.951638
permtest1 QualityTreatmentAgaN4=0.951638
signrank  AVotingCutOffAgainst4=86.7
permtest1  AVotingCutOffAgainst4=86.7

/////////When Partisan Bias was Against and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst5=mean(Willingness2Vote) if Against==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesAgainst5=mean(MeanWTVAgainst5)
by ElectorateID, sort: gen AVotingCutOffAgainst5=AvergesAgainst5 if _n==1
gen QualityTreatmentAgaN5=comb(5,3)*((AVotingCutOffAgainst5/100)^3)*(1-(AVotingCutOffAgainst4/100))^2+0.5*comb(5,2)*((AVotingCutOffAgainst5/100)^2)*(1-(AVotingCutOffAgainst3/100)^5)
mean AVotingCutOffAgainst5
mean QualityTreatmentAgaN5
signrank QualityTreatmentAgaN5=0.880517
permtest1 QualityTreatmentAgaN5=0.880517
signrank  AVotingCutOffAgainst5=67.5
permtest1  AVotingCutOffAgainst5=67.5


/////////When Partisan Bias was Neutral and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral1=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesNeutral1=mean(MeanWTVNeutral1)
by ElectorateID, sort: gen AVotingCutOffNeutral1=AvergesNeutral1 if _n==1
gen QualityTreatmentNeuN1=1-0.5*(1-AVotingCutOffNeutral1/100)
mean AVotingCutOffNeutral1
mean QualityTreatmentNeuN1
signrank QualityTreatmentNeuN1=1
permtest1 QualityTreatmentNeuN1=1
signrank  AVotingCutOffNeutral1=100
permtest1  AVotingCutOffNeutral1=100

/////////When Partisan Bias was Neutral and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral2=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesNeutral2=mean(MeanWTVNeutral2)
by ElectorateID, sort: gen AVotingCutOffNeutral2=AvergesNeutral2 if _n==1
gen QualityTreatmentNeuN2=1-0.5*(1-AVotingCutOffNeutral2/100)^2
mean AVotingCutOffNeutral2
mean QualityTreatmentNeuN2
signrank QualityTreatmentNeuN2=0.959184
permtest1 QualityTreatmentNeuN2=0.959184
signrank  AVotingCutOffNeutral2=71.4
permtest1  AVotingCutOffNeutral2=71.4

/////////When Partisan Bias was Neutral and There were 3 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral3=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesNeutral3=mean(MeanWTVNeutral3)
by ElectorateID, sort: gen AVotingCutOffNeutral3=AvergesNeutral3 if _n==1
gen QualityTreatmentNeuN3=1-0.5*(1-AVotingCutOffNeutral3/100)^3
mean AVotingCutOffNeutral3
mean QualityTreatmentNeuN3
signrank QualityTreatmentNeuN3=0.950269
permtest1 QualityTreatmentNeuN3=0.950269
signrank  AVotingCutOffNeutral3=53.7
permtest1  AVotingCutOffNeutral3=53.7

/////////When Partisan Bias was Neutral and There were 4 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral4=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesNeutral4=mean(MeanWTVNeutral4)
by ElectorateID, sort: gen AVotingCutOffNeutral4=AvergesNeutral4 if _n==1
gen QualityTreatmentNeuN4=1-0.5*(1-AVotingCutOffNeutral4/100)^4
mean AVotingCutOffNeutral4
mean QualityTreatmentNeuN4
signrank QualityTreatmentNeuN4=0.950828
permtest1 QualityTreatmentNeuN4=0.950828
signrank  AVotingCutOffNeutral4=44
permtest1  AVotingCutOffNeutral4=44

/////////When Partisan Bias was Neutral and There were 5 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral5=mean(Willingness2Vote) if Neutral==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesNeutral5=mean(MeanWTVNeutral5)
by ElectorateID, sort: gen AVotingCutOffNeutral5=AvergesNeutral5 if _n==1
gen QualityTreatmentNeuN5=1-0.5*(1-AVotingCutOffNeutral5/100)^5
mean AVotingCutOffNeutral5
mean QualityTreatmentNeuN5
signrank QualityTreatmentNeuN5=0.953074
permtest1 QualityTreatmentNeuN5=0.953074
signrank  AVotingCutOffNeutral5=37.7
permtest1  AVotingCutOffNeutral5=37.7


/////////When Partisan Bias was Supportive and There was 1 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive1=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==1
by ElectorateID, sort: egen AvergesSupportive1=mean(MeanWTVSupportive1)
by ElectorateID, sort: gen AVotingCutOffSupportive1=AvergesSupportive1 if _n==1
gen QualityTreatmentSuppN1=1
mean AVotingCutOffSupportive1
signrank AVotingCutOffSupportive1=0
permtest1 AVotingCutOffSupportive1=0


/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive2=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==2
by ElectorateID, sort: egen AvergesSupportive2=mean(MeanWTVSupportive2)
by ElectorateID, sort: gen AVotingCutOffSupportive2=AvergesSupportive2 if _n==1
gen QualityTreatmentSuppN2=1
mean AVotingCutOffSupportive2
signrank AVotingCutOffSupportive2=0
permtest1 AVotingCutOffSupportive2=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive3=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==3
by ElectorateID, sort: egen AvergesSupportive3=mean(MeanWTVSupportive3)
by ElectorateID, sort: gen AVotingCutOffSupportive3=AvergesSupportive3 if _n==1
gen QualityTreatmentSuppN3=1
mean AVotingCutOffSupportive3
signrank AVotingCutOffSupportive3=0
permtest1 AVotingCutOffSupportive3=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive4=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==4
by ElectorateID, sort: egen AvergesSupportive4=mean(MeanWTVSupportive4)
by ElectorateID, sort: gen AVotingCutOffSupportive4=AvergesSupportive4 if _n==1
gen QualityTreatmentSuppN4=1
mean AVotingCutOffSupportive4
signrank AVotingCutOffSupportive4=0
permtest1 AVotingCutOffSupportive4=0

/////////When Partisan Bias was Supportive and There were 2 Expert Voter////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive5=mean(Willingness2Vote) if Supportive==1&HowManyHaveExpertise==5
by ElectorateID, sort: egen AvergesSupportive5=mean(MeanWTVSupportive5)
by ElectorateID, sort: gen AVotingCutOffSupportive5=AvergesSupportive5 if _n==1
gen QualityTreatmentSuppN5=1
mean AVotingCutOffSupportive5
signrank AVotingCutOffSupportive5=0
permtest1 AVotingCutOffSupportive5=0

restore



preserve
*Now we focus on the behavior of expert voters in the Control Group
drop if Expertise==0
drop if Treatment=="TreatmentGroup"

//////////      When the partisan bias is Against      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVAgainst=mean(Willingness2Vote) if Against==1
by ElectorateID, sort: egen AvergesAgainst=mean(MeanWTVAgainst)
by ElectorateID, sort: gen AVotingCutOffAgainst=AvergesAgainst if _n==1
gen QualityTreatmentAga=comb(5,3)*(0.7*(AVotingCutOffAgainst/100))^3*(1-(0.7*(AVotingCutOffAgainst/100)))^2+comb(5,4)*(0.7*(AVotingCutOffAgainst/100))^4*(1-(0.7*(AVotingCutOffAgainst/100)))^1+comb(5,5)*(0.7*(AVotingCutOffAgainst/100))^5+0.5*comb(5,2)*((0.7*(AVotingCutOffAgainst/100))^2)*(1-(0.7*(AVotingCutOffAgainst/100)))^3
mean AVotingCutOffAgainst
mean QualityTreatmentAga
signrank QualityTreatmentAga=0.878986
permtest1 QualityTreatmentAga=0.878986
signrank  AVotingCutOffAgainst=96.2
permtest1  AVotingCutOffAgainst=96.2

//////////      When the partisan bias is Neutral      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVNeutral=mean(Willingness2Vote) if Neutral==1
by ElectorateID, sort: egen AvergesNeutral=mean(MeanWTVNeutral)
by ElectorateID, sort: gen AVotingCutOffNeutral=AvergesNeutral if _n==1
gen QualityTreatmentNeu=comb(5,1)*(0.7*(AVotingCutOffNeutral/100))*(1-(0.7*(AVotingCutOffNeutral/100)))^4+comb(5,2)*(0.7*(AVotingCutOffNeutral/100))^2*(1-(0.7*(AVotingCutOffNeutral/100)))^3+comb(5,3)*(0.7*(AVotingCutOffNeutral/100))^3*(1-(0.7*(AVotingCutOffNeutral/100)))^2+comb(5,4)*(0.7*(AVotingCutOffNeutral/100))^4*(1-(0.7*(AVotingCutOffNeutral/100)))^1+comb(5,5)*(0.7*(AVotingCutOffNeutral/100))^5+0.5*comb(5,0)*((0.7*(AVotingCutOffNeutral/100))^0)*(1-(0.7*(AVotingCutOffNeutral/100)))^5
mean AVotingCutOffNeutral
mean QualityTreatmentNeu
signrank QualityTreatmentNeu=0.93614
permtest1 QualityTreatmentNeu=0.93614
signrank  AVotingCutOffNeutral=48.2
permtest1  AVotingCutOffNeutral=48.2


//////////      When the partisan bias is Supportive      //////////
sort ElectorateID
by ElectorateID, sort: egen MeanWTVSupportive=mean(Willingness2Vote) if Supportive==1
by ElectorateID, sort: egen AvergesSupportive=mean(MeanWTVSupportive)
by ElectorateID, sort: gen AVotingCutOffSupportive=AvergesSupportive if _n==1
gen QualityTreatmentSupp=1
mean AVotingCutOffSupportive

signrank  AVotingCutOffSupportive=0
permtest1  AVotingCutOffSupportive=0

restore
log close PSRM
